﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;

namespace Module.Core.Common
{
    public class Alert
    {
        #region Ha`m alert khi thu?c hiê?n xong thao ta´c insert
        public static void insertSuccess()
        {
            HttpContext.Current.Response.Write("<script>alert('Bạn đã insert thành công');</script>");
        }
        #endregion

        

        #region Hàm refresh lại trang
        public static void refresh()
        {
            HttpContext.Current.Response.Write("<script>location.href=location.href;</script>");
        }
        #endregion

        #region Ha`m dopostBack sau popup
        public static void PostBackPopup()
        {
            HttpContext.Current.Response.Write("<script>window.top.hidePopWinUSER(false);window.top.__doPostBack('','');</script>");
        }
        public static void PostBackPopupNormal()
        {
            HttpContext.Current.Response.Write("<script>window.top.hidePopWinUSER(false);window.parent.__doPostBack('','');</script>");
        }
        #endregion

        #region Ha`m refresh sau popup
        public static void refreshPopup()
        {
            HttpContext.Current.Response.Write("<script>window.top.hidePopWinUSER(false);window.top.location.href=window.top.location.href;</script>");
        }
        public static void refreshPopupNormal()
        {
            HttpContext.Current.Response.Write("<script>window.top.hidePopWin(false);window.parent.location.href=window.parent.location.href;</script>");
        }
        #endregion

        #region Hàm close modalwindow

        public static void CloseModalWindow(Page g, string returnVal)
        {
            if (!g.ClientScript.IsStartupScriptRegistered("CloseWindow"))
            {

                //ScriptManager.RegisterStartupScript(g, g.GetType(), "CloseWindow",
                //                                    string.Format(
                //                                        "window.returnVal = {0}; window.top.hidePopWinUSER(true);",
                //                                        "'" + returnVal + "'"), true);
            }
        }

        #endregion
    }
}
